package com.innerchic.mapper.tool;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

/**
 * 作者:ZFox
 * 创建:2019/3/5 0005
 * 所属包:cn.xpx.xpx.util
 * 描述: Intent仓库
 **/
public class IntentFactory {

    /**
     * Get a intent
     *
     * @return Intent
     */
    public static Intent getIntent(Context context, Class<?> cls) {
        return new Intent(context, cls);
    }

    /**
     * Get weChart UI page skip intent
     *
     * @return Intent
     */
    public static Intent getWxUiSkipIntentView(String classPathName) {
        ComponentName comp = new ComponentName("com.tencent.mm", "com.tencent.mm" + classPathName);
        Intent intent = new Intent();
        intent.setComponent(comp);
        intent.setAction("android.intent.action.VIEW");
        return intent;
    }

    public static Intent getWxUiSkipIntent(String classPathName) {
        ComponentName comp = new ComponentName("com.tencent.mm", "com.tencent.mm" + classPathName);
        Intent intent = new Intent();
        intent.setComponent(comp);
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        return intent;
    }

    /**
     * Get intent of skip page
     *
     * @return Intent
     */
    public static Intent getSkipPageIntent(String pkg, String cls) {
        ComponentName comp = new ComponentName(pkg, cls);
        Intent intent = new Intent();
        intent.setComponent(comp);
        intent.setAction("android.intent.action.VIEW");
        return intent;
    }

}
